package com.daJiao.controller.api;

import com.daJiao.client.SysFileClient;
import com.daJiao.domain.WrapMapper;
import com.daJiao.domain.Wrapper;
import com.daJiao.properties.OssProperties;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * <p>Title:      SysUploadFileController. </p>
 * <p>Description 文件管理 </p>
 * <p>Company:    北京医百科技有限公司 </p>
 *
 * @author         <a href="xinglinglove1029@163.com"/>杨文生</a>
 * @since      2020/9/10 17:51
 */
@RestController
@RequestMapping(value = "/api/upload", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(tags = "文件管理(API)", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Slf4j
public class ApiUploadFileController {

    @Resource
    private SysFileClient sysFileClient;

    @Resource
    private OssProperties ossProperties;


    @PostMapping(value = "/tencentUpload")
    @ApiOperation(httpMethod = "POST", value = "上传文件(腾讯)")
    public Wrapper<String> txUpload(@RequestParam("file") MultipartFile multipartFile){
        String url = sysFileClient.uploadToTencent(multipartFile);
        return WrapMapper.wrap(Wrapper.SUCCESS_CODE, Wrapper.SUCCESS_MESSAGE,url);
    }

}
